package com.example.hospitaldemo.util;

import lombok.Data;

/**
 * 统一的返回数据集给前端，json数据
 */
@Data
public class ResultData {
    private Integer code;
    private String msg;
    private Long count;
    private Object obj;

    public ResultData(Integer code, String msg, Long count, Object obj) {
        this.code = code;
        this.msg = msg;
        this.count = count;
        this.obj = obj;
    }

    public ResultData(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    public ResultData(Integer code, String msg, Object obj) {
        this.code = code;
        this.msg = msg;
        this.obj = obj;
    }


    public static ResultData success(Long count, Object obj) {
        return new ResultData(200, "操作成功", count, obj);
    }

    public static ResultData success() {
        return new ResultData(200, "操作成功");
    }

    public static ResultData success(Object obj) {
        return new ResultData(200, "操作成功", obj);
    }

    public static ResultData error(Integer code, String msg) {
        return new ResultData(code, msg);
    }
}

